var Common = {
	// 自定义ajax
	ajax : function(url, param, sucFun, errFun) {
		//Common.showProgress("正在请求中...");
		$.ajax({
			"url" : url,
			"data" : param,
			"timeout" : 2000,// 毫秒，2分钟
			"dataType" : "json",
			"type" : "post",
			"error" : function(XMLHttpRequest, textStatus, errorThrown) {// XMLHttpRequest对象，错误信息，（可能）捕获的错误对象
				Common.closeProgress();
				if (errFun) {
					errFun(textStatus);
				} else {
					Common.showAlert("请求错误", XMLHttpRequest.responseText,"error");
				}
			},
			"success" : function(data, textStatus) {// 服务器返回数据，返回状态
				Common.closeProgress();
				if (sucFun) {
					sucFun(data);
				}
			}
		});
	},
	// 进度提示
	showProgress : function(msg) {
		Common.closeProgress();
		$.messager.progress({
			title : '处理进度',// 显示在头部面板上的标题文字，默认值是 ''
			msg : msg,// 消息框的文本，默认值是 ''
			text : '处理中...',// 显示在进度条里的文字，默认值是 undefined
			interval : 1500
		// 每次进度更新之间以毫秒为单位的时间长度。默认值是 300
		});
	},
	// 关闭进度提示
	closeProgress : function() {
		try {
			$.messager.progress('close');
		} catch (error) {

		}
	},
	showAlert : function(title, msg, type, okFun) {
		if (title == null || title == "") {
			title = "提示";
		}
		if (type == null || type == "") {
			type = "info";
		}
		$.messager.defaults = {
			ok : "关闭",
			cancel : "否",
			width : 350
		};
		// type=error、question、info、warning。
		$.messager.alert(title, msg, type, function() {
			if (okFun) {
				okFun();
			}
		});

		/*
		 * $.messager.show({ showType:'slide',//定义消息窗口如何显示。可用的值是：
		 * null、slide、fade、show。默认是 slide。
		 * showSpeed:2000,//定义消息窗口完成显示所需的以毫秒为单位的时间。默认是 600。
		 * width:300,//定义消息窗口的宽度。默认是250。 height:150,//定义消息窗口的高度。默认是100。
		 * msg:msg,//显示的消息文字。 title:title,//头部面板上显示的标题文字。 timeout:1//如果定义为
		 * 0，除非用户关闭，消息窗口将不会关闭。如果定义为非 0 值，消息窗口将在超时后自动关闭。 });
		 */

	},
	// 弹出窗口
	openWindow : function(url, WinWidth, WinHeight) {
		var popwin = window
				.open(
						url,
						"",
						"scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width="
								+ WinWidth
								+ ",height="
								+ WinHeight
								+ ",left="
								+ (screen.width - WinWidth) / 2 + ",top=100");
		popwin.focus();
	},
	showImage:function(imgurl){
		if (imgurl != '') {
			Common.openWindow("/bst/iss?fileName=" + imgurl, 400, 400);
		}
	},
	// 时间戳
    dateFullFormatter : function(value, row, index) {
        if (value != null) {
            var date = new Date(value);
            return Common.dateStrFormatStr(date, "yyyy-MM-dd hh:mm:ss");
        }
    },
 // 日期格式化
    dateStrFormatStr : function(value,row,index) {
		if(value == null || value == "" || value == "null"){
			return "";
		}
        var ts = value || 0;
        var t, y, m, d, h, i, s;
        t = ts ? new Date(ts) : new Date();
        y = t.getFullYear();
        m = t.getMonth() + 1;
        d = t.getDate();
        h = t.getHours();
        i = t.getMinutes();
        s = t.getSeconds();
        // 可根据需要在这里定义时间格式  
        return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + (h < 10 ? '0' + h : h) + ':' + (i < 10 ? '0' + i : i) + ':' + (s < 10 ? '0' + s : s);
    },
	// 获取id串
	getIds : function(rows, attr) {
		if (rows == null || rows.length == 0) {
			return "";
		}
		var idStr = "";
		for (var i = 0; i < rows.length; i++) {
			if (i == rows.length - 1) {
				idStr += rows[i][attr];
			} else {
				idStr += rows[i][attr] + ",";
			}
		}
		return idStr;
	},
	/*
	 * 用来遍历指定对象所有的属性名称和值
	 */
	allPrpos : function(obj) {
		// 用来保存所有的属性名称和值
		var props = "";
		// 开始遍历
		for ( var p in obj) {
			// 方法
			if (typeof (obj[p]) == "function") {
				// obj[p]();
			} else {
				// p 为属性名称，obj[p]为对应属性的值
				props += p + "=" + obj[p] + "\t";
			}
		}
		// 最后显示所有的属性
		alert(props);
	},
	/*
	 * 反馈内容
	 */
	isadoptValue:[{"label":"否","value":"0"},{"label":"是","value":"1"}],
	isadopt : function(value,row,index){
		if (value == "0") {
			return Common.isadoptValue[0].label;
		}else if(value == "1"){
			return Common.isadoptValue[1].label;
		}else{
			return "";
		}

	},
	istatusValue:[{"label":"未处理","value":"0"},{"label":"处理中","value":"1"},{"label":"已处理","value":"2"}],
	istatus : function(value,row,index){
		if (value == "0") {
			return Common.istatusValue[0].label;
		}else if(value == "1"){
			return Common.istatusValue[1].label;
		}else if(value == "2"){
			return Common.istatusValue[2].label;
		}else{
			return "";
		}

	},
	ispassValue:[{"label":"可用","value":"0"},{"label":"禁用","value":"1"}],
	ispass:function (value,row,index) {
		if(value == "0"){
			return Common.ispassValue[0].label;
		} else if(value == "1"){
            return Common.ispassValue[1].label;
        } else {
            return "";
		}

    },
    /*
	 * 是否，对应数据字典
	 */
    yesOrNoValue:[{"label":"是","value":"1"},{"label":"否","value":"2"}],
    yesOrNo : function(value,row,index){
        if (value == "1") {
            return Common.yesOrNoValue[0].label;
        }else if(value == "2"){
            return Common.yesOrNoValue[1].label;
        }else{
            return "";
        }

    },
    /*
     * 租金类型
     */
    renttypeValue:[{"label":"日租金","value":"1"},{"label":"月租金","value":"2"}],
    renttype : function(value,row,index){
        if (value == "1") {
            return Common.renttypeValue[0].label;
        }else if(value == "2"){
            return Common.renttypeValue[1].label;
        }else{
            return "";
        }

    },
    /*
     * 转租求铺
     */
    zpqzValue:[{"label":"转铺","value":"1"},{"label":"求租","value":"2"}],
    zpqztype : function(value,row,index){
        if (value == "1") {
            return Common.zpqzValue[0].label;
        }else if(value == "2"){
            return Common.zpqzValue[1].label;
        }else{
            return "";
        }

    },
    /*
     * 商铺状态
     */
    shopSValue:[{"label":"已转","value":"1"},{"label":"未转","value":"2"}],
    shopStatus : function(value,row,index){
        if (value == "1") {
            return Common.shopSValue[0].label;
        }else if(value == "2"){
            return Common.shopSValue[1].label;
        }else{
            return "";
        }

    },
    /*
     * 处理状态
     */
    handlestateValue:[{"label":"未处理","value":"1"},{"label":"处理中","value":"2"},{"label":"已处理","value":"3"}],
    handlestate : function(value,row,index){
        if (value == "1") {
            return Common.handlestateValue[0].label;
        }else if(value == "2"){
            return Common.handlestateValue[1].label;
        }else if(value == "3"){
            return Common.handlestateValue[2].label;
        }else{
            return "";
        }

    },
    /*
     * 纠错理由
     */
    correcterrorreasonValue:[{"label":"商铺已转出","value":"1"},{"label":"商铺不存在","value":"2"},{"label":"价格不属实","value":"3"},{"label":"面积不属实","value":"4"},{"label":"其他信息不属实","value":"5"}],
    correcterrorreason : function(value,row,index){
        if (value == "1") {
            return Common.correcterrorreasonValue[0].label;
        }else if(value == "2"){
            return Common.correcterrorreasonValue[1].label;
        }else if(value == "3"){
            return Common.correcterrorreasonValue[2].label;
        }else if(value == "4"){
            return Common.correcterrorreasonValue[3].label;
        }else if(value == "5"){
            return Common.correcterrorreasonValue[4].label;
        }else{
            return "";
        }
    },
	//图标
    icons:[{"label":"back","value":"back"},{"label":"blank","value":"blank"},{"label":"cancel","value":"cancel"},{"label":"clear","value":"clear"},{"label":"cut","value":"cut"},{"label":"down","value":"down"},{"label":"edit_add","value":"edit_add"},{"label":"edit_remove","value":"edit_remove"},{"label":"filesave","value":"filesave"},{"label":"filter","value":"filter"},{"label":"folder","value":"folder"},{"label":"folder_table","value":"folder_table"},{"label":"help","value":"help"},{"label":"large_chart","value":"large_chart"},{"label":"large_clipart","value":"large_clipart"},{"label":"large_picture","value":"large_picture"},{"label":"large_shapes","value":"large_shapes"},{"label":"large_smartart","value":"large_smartart"},{"label":"lock","value":"lock"},{"label":"man","value":"man"},{"label":"mini_add","value":"mini_add"},{"label":"mini_edit","value":"mini_edit"},{"label":"mini_refresh","value":"mini_refresh"},{"label":"more","value":"more"},{"label":"no","value":"no"},{"label":"ok","value":"ok"},{"label":"pencil","value":"pencil"},{"label":"print","value":"print"},{"label":"redo","value":"redo"},{"label":"reload","value":"reload"},{"label":"search","value":"search"},{"label":"sum","value":"sum"},{"label":"tip","value":"tip"},{"label":"undo","value":"undo"},{"label":"up","value":"up"}]
}